//
//  OAAccountChangePwsVC.m
//  OA项目
//
//  Created by innofive on 2018/4/13.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAAccountChangePwsVC.h"
#import "OAMeCenterCell.h"
#import "UIBarButtonItem+Extension.h"
#import "OAPwsChangeVC.h"
#import "OAAccountChangeNewVC.h"
#import "NSString+check.h"
@interface OAAccountChangePwsVC ()

@end

@implementation OAAccountChangePwsVC

- (instancetype)initWithStyle:(UITableViewStyle)style Type:(openType)type
{
    self = [super initWithStyle:style];
    if (self) {
        self.type = type;
    }
    return self;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSArray *arr;
    
    if (self.type==openTypePws) {
        
        
        arr = @[ @{@"leftImageName":@"password_icon",
                   @"placeholder":@"请输入登录密码"
                   }
                 ];
    }
    else if (self.type==openTypeAccount)
    {
        arr = @[ @{@"leftImageName":@"phone_icon",
                   @"placeholder":@"请输入新的手机号"
                   }
                 ];
    }else
    {
        arr = @[ @{@"leftImageName":@"password_icon",
                   @"placeholder":@"请输入登录密码"
                   }
                 ];
    }
    
    [self.dataArr addObjectsFromArray:arr];
    
    
    UIBarButtonItem *rightItem =[UIBarButtonItem OnCreateBarBtnItemName:@"下步" BarBtnstyle:(RightBarBtnItemStyle) Btntag:10 target:self action:@selector(onRightButton:)];
//    UIButton *button = (id)[rightItem.customView viewWithTag:10];
    //    [button setNormalTitleColor:[UIColor blackColor]];
    //    [button setSelectTitle:@"完成"];
    //    button.titleLabel.font = kSysFont(kFitW(13));
    self.navigationItem.rightBarButtonItem = rightItem;
    
    
}
-(void)onLoadViewByWillAppear:(UIView *)view
{    view.backgroundColor = hexCOLOR(@"F1F1F1");
    
}

#pragma mark - 点击方法
-(void)onRightButton:(UIButton *)button
{

    if (self.type==openTypePws) {
    
        OAAccountChangePwsVC *vc =[[OAAccountChangePwsVC alloc]initWithStyle:(UITableViewStyleGrouped) Type:openTypeAccount];
        vc.title =self.title;
        [self pushToVC:vc];
        
    }
    else if (self.type==openTypeAccount) {
        UITableViewCell *cell =  [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
        UITextField *textF = [cell.contentView viewWithTag:10];
        
        CHECK([textF.text checkPhoneLength]==NO,@"请输入完整的手机号");
        OAAccountChangeNewVC *vc =[[OAAccountChangeNewVC alloc]init];
        vc.title =self.title;
        vc.textPhone =textF.text;
        [self pushToVC:vc];
    }
    else
    {
        OAPwsChangeVC *vc =[[OAPwsChangeVC alloc]init];
        vc.title =@"输入新密码";
        [self pushToVC:vc];
    
    }
    
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 1;
}


-(MCCellInfo *)tableView:(UITableView *)tableView cellForIndexPath:(NSIndexPath *)indexPath IsHeight:(BOOL)isheight
{
   return [MCCellInfo configForCellId:cell Class:[OAMeCenterCell5 class] Height:kFitH(50) TableView:tableView];
}

-(MCHFViewInfo *)tableView:(UITableView *)tableView HeaderInSection:(NSInteger)section isBiao:(BOOL)isBiao
{
    return [MCHFViewInfo configForViewId:header Class:[OAMeCenterheaderView class] Height:kFitH(10) TableView:tableView IsBian:NO];
}

-(id)cellInitForSourceAtIndexPath:(NSIndexPath *)indexPath
{
    
    return self.dataArr[indexPath.row];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
